package com.gx.cn.hospitalmanage.MyFragmentThree;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.gx.cn.hospitalmanage.R;

/**
 * Created by HCQ on 2018/1/30.
 */

public class PatientMessageActivity extends AppCompatActivity {

    private  String[] sexArry=new String[]{"本人","父母","夫妻","子女","其他"};
     Button btnGuanXii;

    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_patientmessage);
        btnGuanXii= (Button) findViewById(R.id.btnGuanXi);

        btnGuanXii.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showGuanXiChoseDialog();
            }
        });

    }

   private void showGuanXiChoseDialog(){
       AlertDialog.Builder builder=new AlertDialog.Builder(this);//自定义对话框
       builder.setSingleChoiceItems(sexArry, 0, new DialogInterface.OnClickListener() {//默认选中
           @Override
           public void onClick(DialogInterface dialog, int which) { // which是被选中的位置
               btnGuanXii.setText(sexArry[which]);
               dialog.dismiss();  //随便点一个item 消失对话框，不用点击确认取消
           }
       });
       builder.show();
   }

}
